package com.sm.honkon.ui.model

import au.com.safie.user.app.util.CacheUtil
import com.sm.honkon.data.bean.CommonConfig
import com.sm.honkon.data.bean.getDefList
import me.hgj.jetpackmvvm.base.viewmodel.BaseViewModel
import me.hgj.jetpackmvvm.callback.livedata.IntLiveData

class HandheldViewModel : BaseViewModel() {
    val config: CommonConfig = CacheUtil.getCommonConfig()
    val title = when (config.psOrNs.get()) {
        //ps:0001 ns 0010 ns+ps 0100 shouchi 1000
        0b0001 -> "校准: PS"
        0b0010 -> "校准: NS"
        0b0100 -> "校准: PS+NS"
        else -> "校准: 手持"
    }

    fun setDefList() {
        when (selectMode.value) {
            0 -> config.t01064List = getDefList(10)
            1 -> config.t0532List = getDefList(5)
            2 -> config.t21064List = getDefList(10)
            else -> config.t2532List = getDefList(5)
        }
        selectMode.value = selectMode.value
    }

    val selectMode = IntLiveData(
        if (config.psOrNs.get() != 0b0010)
            0
        else
            2
    )

    fun setSelectMode(value: Int) {
        selectMode.value = value
    }


}